<?php
    if($this->_helper->session->get_userdata('jewel_cart_contents'))
        $cart_content = $this->_helper->session->get_userdata('jewel_cart_contents');

?>


<div class="main_right_between" style="min-height: 700px;">
    <div class="viewcart">
    <?php if($cart_content['total_items'] > 0) :?>
        <p class="viewcart_title">Cảm ơn bạn đã mua hàng của chúng tôi. Bạn hãy điền đầy đủ các thông tin ở dưới .</p>

        <div class="viewcart_table">

                <table cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
                            <th>STT</th>
                            <th style="width: 250px;">Tên sản phẩm</th>
                            <th style="width: 125px;">Giá bán</th>
                            <th style="width: 81px;">Số lượng</th>
                            <th style="width: 125px;">Thành tiền</th>
                        </tr>
                    </thead>

                    <tbody>
                        <?php (int) $count = 1; ?>
                        <?php foreach ($cart_content as $key => $value):?>
                            <tr>
                                <?php
                                    if($key === 'cart_total' || $key === 'total_items')
                                        continue;
                                ?>

                                <td><?=$count?></td>
                                <td><?=$value['product_name']?></td>
                                <td><?=number_format($value['price'],0,",",".")?> VNĐ</td>
                                <td><?=$value['quantity']?></td>
                                <td><?=number_format($value['subtotal'],0,",",".")?> VNĐ</td>
                            </tr>

                            <?php $count ++?>
                        <?php endforeach;?>

                        <tr>
                            <td style="text-align: right;" colspan="4">Tổng tiền hàng : </td>
                            <td style="font-weight: bold" colspan="2"><b><?= number_format($cart_content['cart_total'],0,",",".") ?> VNĐ</b></td>
                        </tr>

                    </tbody>
                </table>

        </div><!--End of .viewcart_table -->

        <div id="checkout">
            <h3>Thông tin giao hàng</h3>
            <form id="checkoutform" action="#" method="POST" autocomplete="off">
        		<fieldset>
        			<p id="contact_name">
        				<label for="checkoutname">Họ và tên</label><br />
        				<input class="required" type="text" name="checkoutname" value="" id="checkoutname"/>
        			</p>
        			<p id="contact_email">
        				<label for="checkoutemail">Email</label><br />
        				<input class="required email" type="text" name="checkoutemail" value="" id="checkoutemail"/>
        			</p>

                    <p id="contact_address">
        				<label for="checkoutaddress">Địa chỉ</label><br />
        				<input class="required" type="text" name="checkoutaddress" value="" id="checkoutaddress"/>
        			</p>

        			<p id="contact_phone">
        				<label for="checkoutphone">Điện thoại</label><br />
        				<input class="required number" maxlength="14" type="text" name="checkoutphone" value="" id="checkoutphone"/>
        			</p>

                    <div>
                        <img src="<?=_BASE_URL?>/<?=$captcha['image']?>" />
                    </div>

                    <p id="captcha">
        				<label for="captcha">Captcha</label><br />
        				<input class="required" type="text" name="captcha" value="" id="captcha"/>
                        <input type="hidden" value="<?=$captcha['word']?>" name="txt_cap"/>
        			</p>

        			<p>
        				<label for="comment">Ghi chú</label><br />
        				<textarea cols="30" rows="10" name="comment" id="comment"></textarea>
        			</p>
        		</fieldset>
        		<p><input type="submit" id="checkoutsub" value="SEND"/></p>
        	</form>
        </div><!--End of #checkout -->
    <?php else:?>
    <div id="nocart">
        <p class="viewcart_title" style="text-align: center!important;">Giỏ hàng của bạn không có món hàng nào.</p>
        <p class="error_msg" style="font-size: 1.5em!important;color:#18E2E2!important">Ấn <a href="<?=_BASE_URL?>"><img src="<?=_BASE_URL?>assets/frontend/css/img/back.png" /></a> để quay trở lại.</p>
        <p class="error_msg" style="font-size: 1.5em!important;color:#18E2E2!important">Hoặc</p>
        <p class="viewcart_title" id="cart_msg" style="text-align: center!important;color:#18E2E2!important"></p>
    </div>
    <?php endif;?>
    </div>
	<div class="back"><a href="<?=_BASE_URL?>index.php?module=cart&action=viewcart" title="Quay lại giỏ hàng">Back</a></div>
</div><!--End of .main_right_between -->


<script type="text/javascript" charset="utf-8">
		jQuery(function(){ $("label").inFieldLabels(); });

        /*******VALIDATE FORM*******/
        jQuery("#checkoutform").validate({
            errorElement: "span"

        });
</script>

<script>

// Created by: Jon Brown :: http://allthingsrunescape.freewebs.com
var c=5;
var t;
var domain = 'http://localhost/my_framework';

var check = jQuery("#nocart").length;


function timedCount() {
  document.title='Jewel redirecting ' + c + 's';

  c=c-1;
  if(c>0)
  {
    var msg = 'Hệ thống sẽ tự động chuyển về trang chủ trong ' + c + 's' ;
    jQuery("#cart_msg").html(msg);
  }

  t=setTimeout("timedCount()",1000);
  if (c==-1) {
    clearTimeout(t);
    document.title='Redirecting ...';
    //jQuery("#abc").html(c);
    self.location=domain;
  }
}

if(check > 0)
{
    window.onload=timedCount;
}
</script>



